-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate from httpmock to gock #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great so far!
httpmock.REST("GET", "some/test/path"), | ||
httpmock.StatusStringResponse(200, `{"message": "success"}`), | ||
) | ||
gock.New("https://api.github.com"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of gock.New()
, could we use a gock initialization method that doesn't intercept the default http.DefaultTransport
, but makes a new transport that we can pass via options to RESTClient()
? That way it's more clear what's being initialized, there is no reliance to global state, and we don't have to do t.Cleanup(gock.Off())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we could get around this but this check functionality deep in the gock
implementation makes it infeasible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see; it looks like the library is designed in a way that it always wants to be used with global intercept. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks great
This PR migrates our tests from using our homemade
httpmock
package with the third-partygock
package.gock
provides all the functionality thathttpmock
does and more. It also has a nice declarative DSL that is easier to understand, in my opinion. This is an alternative to #29.cc #28